//Συνδεση του Login με τη βαση δεδομενων μεσω του javaconnect2
package DAO;

import Interfaces.ILogin_Dao;
import Models.Login;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Login_Dao implements ILogin_Dao {

    @Override
    public Login userLogin(String Name, String Pass) throws IllegalArgumentException {

        Connection conn = null;
        ResultSet rs = null;
        PreparedStatement pst = null;
        conn = javaconnect2.connectDB();

        String query = "SELECT * FROM user WHERE username=? and password=?";
        try {
            pst = conn.prepareStatement(query);
            pst.setString(1, Name);
            pst.setString(2, Pass);
            rs = pst.executeQuery();
            
            pst.close();
            conn.close();
        } catch (SQLException e) {
            throw new IllegalArgumentException("Error in Login_Dao ");
        }
        return null;
    }
}
